package com.lxq.serviceImp;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.lxq.dao.UserDao;
import com.lxq.model.User;
import com.lxq.service.UserService;

import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service("userService")
public class UserServiceImp implements UserService {

    @Resource
    private UserDao userDao;


    @Override
    public Page queryUserList(Map<String, Object> map) {

        Page page=new Page();
        //总条数
        page.setTotal(userDao.getUserCount(map));
        //每页显示多少数据
        int pagesize=Integer.parseInt(String.valueOf(map.get("pagesize")));
        page.setPageSize(pagesize);

        //当前页码
        int pagenum=Integer.parseInt(String.valueOf(map.get("pagenum")));
        page.setPageNum(pagenum);

        page= PageHelper.startPage(pagenum,pagesize);

        userDao.getUserList(map);

        return page;
    }




    public UserDao getUserDao() {
        return userDao;
    }

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }
}
